<%@page import="org.omg.CORBA.Request"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>auditing Managements</title>
<link type="text/css" href="JSP/css/style.css" rel="stylesheet"></link>
</head>
<%@include file="../checkSession.jsp"%>
<%@page import="java.util.LinkedList"%>
<%@page import="model.Table"%>
<%@page import="model.User"%>
<%! Boolean x;boolean isAudited;
	LinkedList<Table>list1;
	LinkedList<User>list;
	String owner;
	String obj;%>
<%	x = (Boolean) request.getAttribute("isAudited");
	isAudited = x.booleanValue();
	//isAudited = x.booleanValue();
	list = (LinkedList<User>) request.getAttribute("lstUser");
	list1=(LinkedList<Table>)request.getAttribute("lstTable");
	owner=(String)request.getAttribute("owner");
	obj=(String)request.getAttribute("obj");
	if (list == null) {
		out.println("NULL");
	} else {
		
		for(int i = 0 ; i< list1.size();i++){
			Table t = list1.get(i);
			
			if(t.ownerName.equalsIgnoreCase(owner)) {
				list1.remove(i);
				list1.addFirst(t);
				break;
			}
			
		}

%>
<body>
	<div id="wrap">
		<%@include file="adminHeader.jsp"%>
		<font size="3" face="verdana" color="orange">Auditing
			Managements</font>
		<div class="center_content">
			<%@include file="auditingLeftContent.jsp"%>
			<div class="right_content">
				Object: <select name="Table"
					onchange="window.location.href=this.value">
					<% 	Table t;
						for(int i=0; i<list1.size();i++){
							t = list1.get(i);
					 %>
					<option
						value=<%="./ObjectAudit?owner="+t.ownerName+"&obj="+t.tableName%>><%=t.ownerName+"."+t.tableName%></option>
					<%} %>
				</select>
				<form name="input"
					action=<%="./SubmitObjectAudit?owner="+owner+"&obj="+obj%>
					method="post">
					<table border=1>
						<tr>
							<th class="table-header-repeat line-left minwidth-1">User</th>
							<th class="table-header-repeat line-left">_Select_</th>
							<th class="table-header-repeat line-left">_Insert_</th>
							<th class="table-header-repeat line-left">_Update_</th>
							<th class="table-header-repeat line-left">_Delete_</th>
						</tr>
						<%
							for (int i = 0; i < list.size(); i++) {
								User u = list.get(i);
								String str= u.auditType;
						%>
						<tr>
							<td><%=u.username%></td>
							<%if(str.contains("SELECT")){%>
							<td><input type="checkbox" name=<%="select"+i%>
								checked="checked" /></td>
							<%}else{%>
							<td><input type="checkbox" name=<%="select"+i%> /></td>
							<%}if(str.contains("INSERT")){%>
							<td><input type="checkbox" name=<%="insert"+i%>
								checked="checked" /></td>
							<%}else{%>
							<td><input type="checkbox" name=<%="insert"+i%> /></td>
							<%}if(str.contains("UPDATE")){%>
							<td><input type="checkbox" name=<%="update"+i%>
								checked="checked" /></td>
							<%}else{%>
							<td><input type="checkbox" name=<%="update"+i%> /></td>
							<%}if(str.contains("DELETE")){%>
							<td><input type="checkbox" name=<%="delete"+i%>
								checked="checked" /></td>
							<%}else{%>
							<td><input type="checkbox" name=<%="delete"+i%> /></td>

						</tr>
						<%
								}
							}
						}
						%>
					</table>
					<%if(isAudited){ %>
					<input type="submit" value="Submit" />
					<%}
					else{%>
					<input type="submit" value="Submit" disabled="disabled" /> <font color="red">System Auditing is disable.</font>
					<%} %>
				</form>
				<div class="clear"></div>
			</div>
		</div>
	</div>

</body>
</html>